<template>
  <div class="QuestionType">
    <el-row class="JADP-common-search-box" :gutter="16" v-if="query.cpid">
      <el-form>
        <el-col :span="4">
          <el-form-item label="题型">
            <el-select
              v-model="form.topictype"
              placeholder="请选择题型"
              clearable
            >
              <el-option
                v-for="(item, index) in getDict('topictype')"
                :key="index"
                :value="item.id"
                :label="item.dataName"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="难度">
            <el-select
              v-model="form.difficultion"
              placeholder="请选择难度"
              clearable
            >
              <el-option
                v-for="(item, index) in getDict('difficultion')"
                :key="index"
                :value="item.id"
                :label="item.dataName"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="initData"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh-right" @click="reset()"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <JADP-table v-loading="loading" :data="list" height="310px">
      <!-- <el-table-column prop="papername" label="试卷名称" align="left" /> -->
      <el-table-column prop="stuName" label="学生姓名" align="left" />
      <el-table-column prop="idCard" label="身份证号" align="left" />
      <el-table-column prop="company" label="单位" align="left" />
      <el-table-column prop="score" label="分数" align="left" />
      <el-table-column prop="answerTr" label="答对题数" align="left" />
      <el-table-column prop="answerFa" label="答错题数" align="left" />
      <!-- <el-table-column prop="passinggrade" label="及格分" align="left" /> -->
    </JADP-table>
    <pagination
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      @pagination="initData"
    />
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "QuestionType",
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      form: {
        topictype: "",
        difficultion: ""
      },
      loading: false,
      list: [],
      total: 0,
      listQuery: {
        currentPage: 1,
        pageSize: 20,
        sort: "desc",
        sidx: ""
      }
    };
  },
  methods: {
    initData() {
      this.loading = true;
      let _query = {
        ...this.listQuery,
        ...this.query,
        ...this.form,
        organizeId:this.$store.getters.organizeId
      };
      let query = {};
      for (let key in _query) {
        if (Array.isArray(_query[key])) {
          query[key] = _query[key].join();
        } else {
          query[key] = _query[key];
        }
      }
      request({
        url: `/api/statistics/StatisticsController/TypeAnalysis`,
        method: "get",
        data: query
      }).then(res => {
        console.log(res);
        this.list = res.data.list;
        this.total = res.data.pagination.total;
        this.loading = false;
      });
    },
    reset() {
      for (let key in this.form) {
        this.form[key] = undefined;
      }
      this.initData();
    }
  }
};
</script>
<style scoped lang="scss">
.QuestionType {
  .mysubject {
    margin-bottom: 20px;
    width: 1180px;
    .subject_title {
      width: 1180px;
      .checkbox {
        cursor: pointer;
      }
      .font {
        font-size: 18px;
        font-weight: 600;
      }
      .title_right {
        float: right;
        margin-right: 50px;
      }
    }
    .subject_body {
      width: 1180px;
      margin-top: 20px;
      margin-left: 25px;
      line-height: 22px;
      ul {
        margin-top: 20px;
        li {
          line-height: 30px;
          >>> .el-radio__label {
            font-size: 16px;
          }
        }
      }
    }
  }
}
</style>
